'use strict';

const Service = require('egg').Service;

class UserService extends Service {

	get tbname(){
		return 'yz_user';
	}

	async getUserByToken(token){

		if(!token){
			return null;
		}
		const { app } = this;
		let user = app.mysql.get(this.tbname, { active_code: token });
		return user;
	}

	async create(user){
		const { app } = this;
		let result = app.mysql.insert(this.tbname, user);
		return result;
	}
}

module.exports = UserService;